<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>登入页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<script type="text/javascript" src="${ctx}/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${ctx}/js/login.js"></script>
<link rel="shortcut icon" href="${ctx}/icon/ali.gif" type="image/gif" />
<link rel="stylesheet" href="${ctx}/css/pintuer.css">
<link rel="stylesheet" href="${ctx}/css/admin.css">
<link rel="stylesheet" href="${ctx}/font_awesome_4_7_0/css/font-awesome.min.css">
<link rel="stylesheet" href="${ctx}/css/common.css">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="${ctx}/layui/layui.all.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/layui/css/layui.css">
<script type="text/javascript" src="${ctx}/js/layui_common.js"></script>
<script type="text/javascript">
function login(){
	var username = $("#username").val();
	if(username == null || username == "" || username == undefined){
		//提示不能为空
		layer.alert("登录账户不能为空!");
		return ;
	}
	var password = $("#password").val();
	if(password == null || password == "" || password == undefined){
		//提示不能为空
		layer.alert("登录密码不能为空!");
		return ;
	}
	$.ajax({
		url:'${ctx}/admin/login',
		data:{"username":username,"password":password},
		type:'post',
		dataType:'html',
		success:function(data){
			if(data==-1){
				layer.alert("用户名或者密码错误");
			}else if(data==-2){
				layer.alert("用户不存在");
			}else{
				window.location.href="${ctx}/admin/manager/index";
			}
		}
	});
}

function keyLogin(){
	if (event.keyCode==13){//回车键的键值为13
		login();//调用登录按钮的登录事件
	}  
}
</script>
</head>

<body onkeydown="keyLogin();">
	<div class="bg"></div>
	<div class="container">
		<div class="line bouncein">
			<div class="xs6 xm4 xs3-move xm4-move">
				<div style="height: 150px;"></div>
				<div class="media media-y margin-big-bottom"></div>

				<div class="panel loginbox">
					<div class="text-center margin-big padding-big-top">
						<h1>后台管理中心</h1>
					</div>
					<div class="panel-body"
						style="padding: 30px; padding-bottom: 10px; padding-top: 10px;">
						<div class="form-group">
							<div class="field field-icon-right">
								<input type="text" class="input input-big" name="username" value="${username}"
									id="username" class="username" placeholder="登录账号"/> <span
									class="icon icon-user margin-small"></span>
							</div>
						</div>
						<div class="form-group">
							<div class="field field-icon-right">
								<input type="password" class="input input-big" name="password"
									id="password" class="password" placeholder="登录密码"/> <span
									class="icon icon-key margin-small"></span>
							</div>
						</div>
						<%-- <div class="form-group">
							<div class="field">
								<input type="text" class="input input-big"
									name="verificationCode" id="verificationCode"
									placeholder="填写右侧的验证码" data-validate="required:请填写右侧的验证码" />
								<img src="<%=basePath%>/validateCode.shtml"
									id="verifyCodeImage" alt=" " width="100" height="32"
									class="passcode" style="height: 43px; cursor: pointer;"
									onclick="this.src=this.src+'?' ">

							</div>
						</div> --%>

						<div class="form-group">
							<div class="field"><h6 style="color: red">${message}</h6></div>
						</div>
					</div>
					<div style="padding: 30px;">
						<input type="submit"
							class="button button-block bg-main text-big input-big"
							value="登录" onclick="login();">
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
